package main

import "fmt"

// 结构体首字母大写表示这个结构体是公有的，在其他包中可以访问
// 结构体的字段名首字母小写表示这个字段是私有的，只能在当前包中访问
type Books struct {
	title   string
	author  string
	subject string
	book_id int
}

// func changeBook(book Books) {
// 	book.title = "book1_change"
// }

func changeBook(book *Books) {
	book.title = "book1_change"
}

func main() {
	var book = new(Books) // 声明结构体变量 引用类型
	// var p = &Books{} // 声明结构体变量 指针类型
	// var p1 = Books{
	// 	title: "Go 语言学习",} // 声明结构体变量 值类型
	book.title = "Go 语言学习"
	book.author = "000"
	book.subject = "Go 语言"
	book.book_id = 001
	fmt.Println(book)

	var book1 Books
	book1.title = "Go 语言学习"
	book1.author = "000"
	book1.subject = "Go 语言"
	book1.book_id = 001
	fmt.Println(book1)
	//  changeBook(book1)
	//  fmt.Println(book1)
	changeBook(&book1)
	fmt.Println(book1)
	fmt.Printf("值是%#v\n", book1)

	var p4 = Books{title: "Go 语言学习", author: "000", subject: "Go 语言", book_id: 001}
	fmt.Println(p4)
	var p5 = &Books{title: "Go 语言学习", author: "000", subject: "Go 语言", book_id: 001}
	fmt.Println(p5)
	fmt.Printf("值是%#v\n", p5)

}
